﻿using System.Collections.Generic;
using UnityEngine;

namespace Framework
{
    public static class WorldRenderManager
    {
        static Dictionary<Vector3Int, GameObject> chunks = new Dictionary<Vector3Int, GameObject>();

        static public void DisplayChunk(Chunk chunk)
        {
            if (chunks.ContainsKey(chunk.position))
            {
                chunks[chunk.position].SetActive(true);
            }
            else
            {
                chunks.Add(chunk.position, ChunkRender.RenderChunk(chunk));
            }
        }
        static public void HideChunk(Chunk chunk)
        {
            if (chunks.ContainsKey(chunk.position))
            {
                chunks[chunk.position].SetActive(false);
            }
        }
        static public void DestoryChunk(Chunk chunk)
        {
            if (chunks.ContainsKey(chunk.position))
            {
                GameObject.Destroy(chunks[chunk.position]);
                chunks.Remove(chunk.position);
            }
        }
    }
}